home *** CD-ROM | disk | FTP | other *** search
- /* PropSliders.c
- This code demonstrates Sliders, how to create,
- how to read.
-
- Patrick Hager, Great Valley Products Inc.
- November 2, 1993
- */
-
-
- #include <stdio.h>
- #include "/global/userwindow.h"
- #include "/global/egslibraries.h"
-
- #include <clib/alib_protos.h>
- #include <clib/exec_protos.h>
- #include <egs/egsintui.h>
- #include <egs/clib/egsintui_protos.h>
- #include <egs/pragmas/egsintui_pragmas.h>
- #include <egs/egsgadbox.h>
- #include <egs/clib/egsgadbox_protos.h>
- #include <egs/pragmas/egsgadbox_pragmas.h>
- #include <egs/egb/gbtwodimprop.h>
- #include <egs/clib/gbtwodimprop_protos.h>
- #include <egs/pragmas/gbtwodimprop_pragmas.h>
-
-
-
- #define CHOICES_ID 100 // Gadget ID base for 3 Main Window Choice
- // Gadgets.
-
- #define HORIZ1INT_ID 200 // More Gadget IDs
- #define HORIZ1SLIDER_ID 201
- #define HORIZ2INT_ID 250
- #define HORIZ2SLIDER_ID 251
-
- #define VERTI1INT_ID 200
- #define VERTI1SLIDER_ID 201
- #define VERTI2INT_ID 250
- #define VERTI2SLIDER_ID 251
-
- #define TWODIM_ID 300
- #define TWODIM_INTGAD_X_ID 302
- #define TWODIM_INTGAD_Y_ID 304
- // Our UserInputWindow structure for the main
- // Window.
- static struct UserInputWindow Main_Request;
- // Our UserInputWindow structure for the
- // Horizontal Sliders Example Window.
- static struct UserInputWindow Horiz_Request;
- // Our UserInputWindow structure for the
- // Vertical Sliders Example Window.
- static struct UserInputWindow Verti_Request;
- // Our UserInputWindow structure for the
- // 2-Dim Sliders Example Window.
- static struct UserInputWindow TwoDim_Request;
-
-
- /* For this example, we are using multiple
- windows, so it is necessary to open a
- message port of our own, in order for
- all the windows to share a port.
- */
- static struct MsgPort *ExamplePort;
-
-
- static BYTE Quit_Example=0;
- static WORD Horiz1_Value=0; // Current value of Horiz Slider 1.
- static WORD Horiz2_Value=0; // Current value of Horiz Slider 2.
- static WORD Verti1_Value=0; // Current value of Verti Slider 1.
- static WORD Verti2_Value=0; // Current value of Verti Slider 2.
- static WORD TwoDimX_Value=0; // Current X value of Two Dim Prop Gadget.
- static WORD TwoDimY_Value=0; // Current Y value of Two Dim Prop Gadget.
-
- // Local PRIVATE function Prototypes.
-
- EB_GadBoxPtr Create_Main (UserInputWindowPtr UserWindow);
- void GadgetDown_Main (UserInputWindowPtr UserWindow, EI_GadgetPtr iaddress);
- void Close_Main (UserInputWindowPtr UserWindow);
-
-
- EB_GadBoxPtr Create_Horiz (UserInputWindowPtr UserWindow);
- void GadgetDown_Horiz (UserInputWindowPtr UserWindow, EI_GadgetPtr iaddress);
- void Redraw_Horiz (UserInputWindowPtr UserWindow);
-
- EB_GadBoxPtr Create_Verti (UserInputWindowPtr UserWindow);
- void GadgetDown_Verti (UserInputWindowPtr UserWindow, EI_GadgetPtr iaddress);
- void Redraw_Verti (UserInputWindowPtr UserWindow);
-
- EB_GadBoxPtr Create_TwoDim (UserInputWindowPtr UserWindow);
- void GadgetDown_TwoDim (UserInputWindowPtr UserWindow, EI_GadgetPtr iaddress);
- void Redraw_TwoDim (UserInputWindowPtr UserWindow);
-
- /****************************
- MAIN CODE
- ****************************/
- void main (void) {
- EI_EIntuiMsgPtr Mesg;
-
- if (OpenEGSLibraries ()) {
- if (ExamplePort = CreatePort (0,0)) {
- Init_UserWindow (&Main_Request, "Slider Example Main Window",WINDOW_NONMODAL,
- NULL,ExamplePort);
- Init_UserWindow (&Horiz_Request, "Horizontal Sliders Example Window",WINDOW_NONMODAL,
- NULL,ExamplePort);
- Init_UserWindow (&Verti_Request, "Vertical Sliders Example Window",WINDOW_NONMODAL,
- NULL,ExamplePort);
- Init_UserWindow (&TwoDim_Request, "TwoDimSliders Example Window",WINDOW_NONMODAL,
- NULL,ExamplePort);
-
- Main_Request.Create = Create_Main;
- Main_Request.GadgetDown = GadgetDown_Main;
- Main_Request.Close = Close_Main;
-
- Horiz_Request.Create = Create_Horiz;
- Horiz_Request.GadgetDown = GadgetDown_Horiz;
- Horiz_Request.Redraw = Redraw_Horiz;
-
- Verti_Request.Create = Create_Verti;
- Verti_Request.GadgetDown = GadgetDown_Verti;
- Verti_Request.Redraw = Redraw_Verti;
-
- TwoDim_Request.Create = Create_TwoDim;
- TwoDim_Request.GadgetDown = GadgetDown_TwoDim;
- TwoDim_Request.Redraw = Redraw_TwoDim;
-
- Main_Request.IDCMPFlags =
- Horiz_Request.IDCMPFlags =
- Verti_Request.IDCMPFlags =
- TwoDim_Request.IDCMPFlags = EI_iCLOSEWINDOW | EI_iSIZEVERIFY |
- EI_iNEWSIZE | EI_iGADGETDOWN;
-
- Main_Request.Flags =
- Horiz_Request.Flags =
- Verti_Request.Flags =
- TwoDim_Request.Flags = EI_SIZEBBOTTOM | EI_SIMPLE_REFRESH |
- EI_GIMMEZEROZERO;
-
- Main_Request.SysGadgets =
- Horiz_Request.SysGadgets =
- Verti_Request.SysGadgets =
- TwoDim_Request.SysGadgets = EI_WINDOWCLOSE | EI_WINDOWSIZE |
- EI_WINDOWDRAG|EI_WINDOWBACK;
-
- if (Open_UserWindow (&Main_Request,-1,-1)) {
- while (!Quit_Example) {
- WaitPort (ExamplePort);
- while (Mesg=(struct EI_EIntuiMsg *)GetMsg (ExamplePort)) {
- if ( ((WindowInfoPtr)Mesg->IDCMPWindow->UserData)->EventHandler) {
- ((WindowInfoPtr)Mesg->IDCMPWindow->UserData)->EventHandler (Mesg);
- }
- }
- }
- Close_All_UserWindows ();
- }
- else {
- printf ("Couldn't open my window!\n");
- }
- DeletePort (ExamplePort);
- }
- }
- CloseEGSLibraries (); // after the bracket cause what if I opened 3 but
- // couldn't find the rest, still need to close the 3.
- }
-
- /*************************************
- PRIVATE: Create_Main.
- This routine is called by the UserWindow routines.
- It passes back a GadBoxPtr to the gadgets wanted.
- *************************************/
- EB_GadBoxPtr Create_Main (UserInputWindowPtr UserWindow) {
- EB_GadBoxPtr root;
- EB_GadContext gadcon;
-
- gadcon = UserWindow->GadCon;
-
- root = EB_CreateVertiBox (gadcon);
- EB_AddLastSon (root,EB_CreateVertiFill (gadcon,0,0));
- EB_AddLastSon (root,EB_CreateTextAction (gadcon,"Horizontal Sliders",CHOICES_ID+0,EB_FILL_ALL));
- EB_AddLastSon (root,EB_CreateVertiFill (gadcon,0,0));
- EB_AddLastSon (root,EB_CreateTextAction (gadcon,"Vertical Sliders",CHOICES_ID+1,EB_FILL_ALL));
- EB_AddLastSon (root,EB_CreateVertiFill (gadcon,0,0));
- EB_AddLastSon (root,EB_CreateTextAction (gadcon,"Two Dimensional Sliders",CHOICES_ID+2,EB_FILL_ALL));
- EB_AddLastSon (root,EB_CreateVertiFill (gadcon,0,0));
- return root;
- }
-
- /**************************************
- PRIVATE: GadgetDown_Main.
- This routine handles the gadget down events passed to the
- Main Control Window.
- **************************************/
- void GadgetDown_Main (UserInputWindowPtr UserWindow, EI_GadgetPtr iaddress) {
-
- switch (iaddress->GadgetID) {
- case CHOICES_ID+0:
- Open_UserWindow (&Horiz_Request,-1,-1);
- break;
- case CHOICES_ID+1:
- Open_UserWindow (&Verti_Request,-1,-1);
- break;
- case CHOICES_ID+2:
- Open_UserWindow (&TwoDim_Request,-1,-1);
- break;
- }
- }
-
-
-
- /*************************************
- PRIVATE: Close_Main.
- This routine CANNOT be used to close the Main
- Control Window!!! It is called by the UserWindow
- routines to allow this window to clean up any
- allocated memory.
- To Close the Main Control Window, call
- CloseDown_Main ();
- *************************************/
- void Close_Main (UserInputWindowPtr UserWindow) {
-
- // When the main window quits, we all quit!
- Quit_Example = 1;
- }
-
-
- /************************************************
- Functions for the Horizontal Slider Example Window.
- ************************************************/
-
-
-
- /*************************************
- PRIVATE: Create_Horiz.
- This routine is called by the UserWindow routines.
- It passes back a GadBoxPtr to the gadgets wanted.
- *************************************/
- EB_GadBoxPtr Create_Horiz (UserInputWindowPtr UserWindow) {
- EB_GadBoxPtr root, horiz, box;
- EB_GadContext gadcon;
-
- gadcon = UserWindow->GadCon;
-
- root = EB_CreateVertiBox (gadcon);
- EB_AddLastSon (root,EB_CreateVertiFill (gadcon,0,0));
-
- horiz=EB_CreateHorizBox (gadcon);
- EB_AddLastSon (horiz,EB_CreateHorizFill (gadcon,0,0));
- EB_AddLastSon (horiz,EB_CreateText (gadcon,"Update on release:"));
- EB_AddLastSon (horiz,EB_CreateHorizFill (gadcon,0,0));
- // Integer Gadgets have no natural borders
- // around them, so we add it to a back border.
- box=EB_CreateBackBorder (gadcon,EB_CreateIntegerGadget (gadcon,4,3,HORIZ1INT_ID),
- EB_FILL_ALL);
- // We don't want the integer gadget to get bigger,
- // because it still would only have 3 places
- // (0-100), so we knock its priority to lowest.
- EB_NewPri (box,-1);
- EB_AddLastSon (horiz,box);
- EB_AddLastSon (horiz,EB_CreateHorizFill (gadcon,0,0));
- box=EB_CreateSuperHorizProp (gadcon,120,20,Horiz1_Value,HORIZ1SLIDER_ID,
- EB_DEC_UP_LEFT | EB_INC_UP_LEFT);
- // The sliders will open very small if left to
- // themselves. Here I demand it opens a bit
- // larger. Comment out this line, as well as
- // the next sliders's NewMinWidth to see what I
- // mean.
- EB_NewMinWidth (box,120);
- EB_AddLastSon (horiz,box);
- EB_AddLastSon (horiz,EB_CreateHorizFill (gadcon,0,0));
- EB_AddLastSon (root,horiz);
- horiz=EB_CreateHorizBox (gadcon);
- EB_AddLastSon (horiz,EB_CreateHorizFill (gadcon,0,0));
- EB_AddLastSon (horiz,EB_CreateText (gadcon,"Update immediatly:"));
- EB_AddLastSon (horiz,EB_CreateHorizFill (gadcon,0,0));
- box=EB_CreateBackBorder (gadcon,EB_CreateIntegerGadget (gadcon,4,3,HORIZ2INT_ID),
- EB_FILL_ALL);
- EB_NewPri (box,-1);
- EB_AddLastSon (horiz,box);
- EB_AddLastSon (horiz,EB_CreateHorizFill (gadcon,0,0));
- box=EB_CreateSuperHorizProp (gadcon,120,20,Horiz2_Value,
- HORIZ2SLIDER_ID,
- EB_DEC_UP_LEFT | EB_INC_UP_LEFT);
- // This slider will now give a gadget down
- // message every time its value changes.
- // (Make sure you can process this many messages!)
- ((EB_SPropGadPtr)box->Render.Gad)->RealProp->Propflags |= EI_PROP_FOLLOW;
- EB_NewMinWidth (box,120);
- EB_AddLastSon (horiz,box);
- EB_AddLastSon (horiz,EB_CreateHorizFill (gadcon,0,0));
- EB_AddLastSon (root,horiz);
-
- return root;
- }
-
- /**************************************
- PRIVATE: GadgetDown_Horiz.
- This routine handles the gadget down events passed to the
- Horiz Control Window.
- **************************************/
- void GadgetDown_Horiz (UserInputWindowPtr UserWindow, EI_GadgetPtr iaddress) {
- EI_GadgetPtr tgad;
- WORD value;
-
- switch (iaddress->GadgetID) {
- case HORIZ1INT_ID:
- value=((EI_IntGadPtr)iaddress)->Value;
- // Good value. Update Slider.
- if ((value>=0)&&(value<100)) {
- Horiz1_Value=value;
- if (tgad=myFindGadget (UserWindow->GadCon,HORIZ1SLIDER_ID)) {
- ((EB_SPropGadPtr)tgad)->RealProp->Value=Horiz1_Value;
- EI_RefreshGadget (UserWindow->Window,tgad);
- }
-
- }
- // Bad Value. Change Int Gad back to old value.
- else {
- EB_PutIntData (UserWindow->Window,iaddress,Horiz1_Value);
- EI_RefreshGadget (UserWindow->Window,iaddress);
- }
- break;
- case HORIZ1SLIDER_ID:
- if (tgad=myFindGadget (UserWindow->GadCon,HORIZ1INT_ID)) {
- Horiz1_Value=((EB_SPropGadPtr)iaddress)->RealProp->Value;
- EB_PutIntData (UserWindow->Window,tgad,Horiz1_Value);
- }
- break;
- case HORIZ2INT_ID:
- value=((EI_IntGadPtr)iaddress)->Value;
- // Good value. Update Slider.
- if ((value>=0)&&(value<100)) {
- Horiz2_Value=value;
- if (tgad=myFindGadget (UserWindow->GadCon,HORIZ2SLIDER_ID)) {
- ((EB_SPropGadPtr)tgad)->RealProp->Value=Horiz2_Value;
- EI_RefreshGadget (UserWindow->Window,tgad);
- }
- }
- // Bad Value. Change Int Gad back to old value.
- else {
- EB_PutIntData (UserWindow->Window,iaddress,Horiz2_Value);
- EI_RefreshGadget (UserWindow->Window,iaddress);
- }
-
- break;
- case HORIZ2SLIDER_ID:
- if (tgad=myFindGadget (UserWindow->GadCon,HORIZ2INT_ID)) {
- Horiz2_Value=((EB_SPropGadPtr)iaddress)->RealProp->Value;
- EB_PutIntData (UserWindow->Window,tgad,Horiz2_Value);
- }
- break;
- }
- }
-
- /**************************************
- PUBLIC: Redraw_Horiz.
- This routine is called on a EI_iREFRESHWINDOW message.
- If you have nothing to refresh, set the Horiz_Request.Refresh
- to NULL.
- **************************************/
- void Redraw_Horiz (UserInputWindowPtr UserWindow) {
- EI_GadgetPtr tgad;
-
- // EB_PutIntData automatically refreshes the gadget if
- // its on screen.
- if (tgad=myFindGadget (UserWindow->GadCon,HORIZ1INT_ID)) {
- EB_PutIntData (UserWindow->Window,tgad,Horiz1_Value);
- }
- // Since there is no function to update a slider, we
- // must do it manually, then refresh the gadget ourselves.
- if (tgad=myFindGadget (UserWindow->GadCon,HORIZ1SLIDER_ID)) {
- ((EB_SPropGadPtr)tgad)->RealProp->Value=Horiz1_Value;
- EI_RefreshGadget (UserWindow->Window,tgad);
- }
- if (tgad=myFindGadget (UserWindow->GadCon,HORIZ2INT_ID)) {
- EB_PutIntData (UserWindow->Window,tgad,Horiz2_Value);
- }
- if (tgad=myFindGadget (UserWindow->GadCon,HORIZ2SLIDER_ID)) {
- ((EB_SPropGadPtr)tgad)->RealProp->Value=Horiz2_Value;
- EI_RefreshGadget (UserWindow->Window,tgad);
- }
- }
-
- /******************************************************
- Functions for the Vertical Sliders Example Window.
- *******************************************************/
-
-
- /*************************************
- PRIVATE: Create_Verti.
- This routine is called by the UserWindow routines.
- It passes back a GadBoxPtr to the gadgets wanted.
- *************************************/
- EB_GadBoxPtr Create_Verti (UserInputWindowPtr UserWindow) {
- EB_GadBoxPtr root, verti, box;
- EB_GadContext gadcon;
-
- gadcon = UserWindow->GadCon;
- /* Note the difference in the sizeing of the
- Prop gadgets given who they share the Vertical
- Box with, the first, a long text string, the
- second, a short one...
- */
-
- root = EB_CreateHorizBox (gadcon);
- EB_AddLastSon (root,EB_CreateHorizFill (gadcon,0,0));
- verti=EB_CreateVertiBox (gadcon);
- EB_AddLastSon (verti,EB_CreateVertiFill (gadcon,0,0));
- EB_AddLastSon (verti,EB_CreateText (gadcon,"Update on release:"));
- EB_AddLastSon (verti,EB_CreateVertiFill (gadcon,0,0));
- box=EB_CreateSuperVertiProp (gadcon,120,20,Verti1_Value,VERTI1SLIDER_ID,
- EB_DEC_UP_LEFT | EB_INC_UP_LEFT);
- // The sliders will open very small if left to
- // themselves. Here I demand it opens a bit
- // larger. Comment out this line, as well as
- // the next sliders's NewMinHeight to see what I
- // mean.
- EB_NewMinHeight (box,120);
- EB_AddLastSon (verti,box);
- // Integer Gadgets have no natural borders
- // around them, so we add it to a back border.
- box=EB_CreateBackBorder (gadcon,EB_CreateIntegerGadget (gadcon,4,3,VERTI1INT_ID),
- EB_FILL_ALL);
- // We don't want the integer gadget to get bigger,
- // because it still would only have 3 places
- // (0-100), so we knock its priority to lowest.
- EB_NewPri (box,-1);
- EB_AddLastSon (verti,box);
- EB_AddLastSon (verti,EB_CreateVertiFill (gadcon,0,0));
- EB_AddLastSon (root,verti);
- verti=EB_CreateVertiBox (gadcon);
- EB_AddLastSon (verti,EB_CreateVertiFill (gadcon,0,0));
- EB_AddLastSon (verti,EB_CreateText (gadcon,"Con:"));
- EB_AddLastSon (verti,EB_CreateVertiFill (gadcon,0,0));
- box=EB_CreateSuperVertiProp (gadcon,120,20,Verti2_Value,VERTI2SLIDER_ID,
- EB_DEC_BOTTOM_RIGHT | EB_INC_UP_LEFT);
- // The sliders will open very small if left to
- // themselves. Here I demand it opens a bit
- // larger. Comment out this line, as well as
- // the next sliders's NewMinHeight to see what I
- // mean.
- EB_NewMinHeight (box,120);
- // This slider will now give a gadget down
- // message every time its value changes.
- // (Make sure you can process this many messages!)
- ((EB_SPropGadPtr)box->Render.Gad)->RealProp->Propflags |= EI_PROP_FOLLOW;
- EB_AddLastSon (verti,box);
- // Integer Gadgets have no natural borders
- // around them, so we add it to a back border.
- box=EB_CreateBackBorder (gadcon,EB_CreateIntegerGadget (gadcon,4,3,VERTI2INT_ID),
- EB_FILL_ALL);
- // We don't want the integer gadget to get bigger,
- // because it still would only have 3 places
- // (0-100), so we knock its priority to lowest.
- EB_NewPri (box,-1);
- EB_AddLastSon (verti,box);
- EB_AddLastSon (verti,EB_CreateVertiFill (gadcon,0,0));
- EB_AddLastSon (root,verti);
-
- return root;
- }
-
- /**************************************
- PRIVATE: GadgetDown_Verti.
- This routine handles the gadget down events passed to the
- Verti Control Window.
- **************************************/
- void GadgetDown_Verti (UserInputWindowPtr UserWindow, EI_GadgetPtr iaddress) {
- EI_GadgetPtr tgad;
- WORD value;
-
- switch (iaddress->GadgetID) {
- case VERTI1INT_ID:
- value=((EI_IntGadPtr)iaddress)->Value;
- // Good value. Update Slider.
- if ((value>=0)&&(value<100)) {
- Verti1_Value=value;
- if (tgad=myFindGadget (UserWindow->GadCon,VERTI1SLIDER_ID)) {
- ((EB_SPropGadPtr)tgad)->RealProp->Value=Verti1_Value;
- EI_RefreshGadget (UserWindow->Window,tgad);
- }
- }
- // Bad Value. Change Int Gad back to old value.
- else {
- EB_PutIntData (UserWindow->Window,iaddress,Verti1_Value);
- EI_RefreshGadget (UserWindow->Window,iaddress);
- }
- break;
- case VERTI1SLIDER_ID:
- if (tgad=myFindGadget (UserWindow->GadCon,VERTI1INT_ID)) {
- Verti1_Value=((EB_SPropGadPtr)iaddress)->RealProp->Value;
- EB_PutIntData (UserWindow->Window,tgad,Verti1_Value);
- }
- break;
- case VERTI2INT_ID:
- value=((EI_IntGadPtr)iaddress)->Value;
- // Good value. Update Slider.
- if ((value>=0)&&(value<100)) {
- Verti2_Value=value;
- if (tgad=myFindGadget (UserWindow->GadCon,VERTI2SLIDER_ID)) {
- ((EB_SPropGadPtr)tgad)->RealProp->Value=Verti2_Value;
- EI_RefreshGadget (UserWindow->Window,tgad);
- }
- }
- // Bad Value. Change Int Gad back to old value.
- else {
- EB_PutIntData (UserWindow->Window,iaddress,Verti2_Value);
- EI_RefreshGadget (UserWindow->Window,iaddress);
- }
- break;
- case VERTI2SLIDER_ID:
- if (tgad=myFindGadget (UserWindow->GadCon,VERTI2INT_ID)) {
- Verti2_Value=((EB_SPropGadPtr)iaddress)->RealProp->Value;
- EB_PutIntData (UserWindow->Window,tgad,Verti2_Value);
- }
- break;
- }
- }
-
- /**************************************
- PUBLIC: Redraw_Verti.
- This routine is called on a EI_iREFRESHWINDOW message.
- If you have nothing to refresh, set the Verti_Request.Refresh
- to NULL.
- **************************************/
- void Redraw_Verti (UserInputWindowPtr UserWindow) {
- EI_GadgetPtr tgad;
-
- // EB_PutIntData automatically refreshes the gadget if
- // its on screen.
- if (tgad=myFindGadget (UserWindow->GadCon,VERTI1INT_ID)) {
- EB_PutIntData (UserWindow->Window,tgad,Verti1_Value);
- }
- // Since there is no function to update a slider, we
- // must do it manually, then refresh the gadget ourselves.
- if (tgad=myFindGadget (UserWindow->GadCon,VERTI1SLIDER_ID)) {
- ((EB_SPropGadPtr)tgad)->RealProp->Value=Verti1_Value;
- EI_RefreshGadget (UserWindow->Window,tgad);
- }
- if (tgad=myFindGadget (UserWindow->GadCon,VERTI2INT_ID)) {
- EB_PutIntData (UserWindow->Window,tgad,Verti2_Value);
- }
- if (tgad=myFindGadget (UserWindow->GadCon,VERTI2SLIDER_ID)) {
- ((EB_SPropGadPtr)tgad)->RealProp->Value=Verti2_Value;
- EI_RefreshGadget (UserWindow->Window,tgad);
- }
- }
-
-
- /************************************************************
- Functions for the TwoDimensional Prop Gadget Example Window.
- ************************************************************/
-
-
-
- /*************************************
- PRIVATE: Create_TwoDim.
- This routine is called by the UserWindow routines.
- It passes back a GadBoxPtr to the gadgets wanted.
- *************************************/
- EB_GadBoxPtr Create_TwoDim (UserInputWindowPtr UserWindow) {
- EB_GadBoxPtr root, horiz, box;
- EB_GadContext gadcon;
-
- gadcon = UserWindow->GadCon;
-
- root = EB_CreateVertiBox (gadcon);
- box = EGB_CreateTwoDPropGadget (gadcon,120,20,0,120,20,0,TWODIM_ID);
- EB_NewPri (box,-1);
- // This should work... but it doesn't.
- // I'll contact Viona, there must be a way...
- ((EGB_TwoDimPropGadPtr)box)->Propflags |= EI_PROP_FOLLOW;
- EB_AddLastSon (root,EB_CreateGroupBorder (gadcon,box,NULL," Two Dim Prop Gadget"));
- horiz=EB_CreateHorizBox (gadcon);
- EB_AddLastSon (horiz,EB_CreateHorizFill (gadcon,0,0));
- EB_AddLastSon (horiz,EB_CreateText (gadcon,"X:"));
- EB_AddLastSon (horiz,EB_CreateHorizFill (gadcon,0,0));
- box=EB_CreateBackBorder (gadcon,EB_CreateIntegerGadget (gadcon,4,3,
- TWODIM_INTGAD_X_ID),
- EB_FILL_ALL);
- EB_NewPri (box,-1);
- EB_AddLastSon (horiz,box);
- EB_AddLastSon (horiz,EB_CreateText (gadcon,"Y:"));
- EB_AddLastSon (horiz,EB_CreateHorizFill (gadcon,0,0));
- box=EB_CreateBackBorder (gadcon,EB_CreateIntegerGadget (gadcon,4,3,
- TWODIM_INTGAD_Y_ID),
- EB_FILL_ALL);
- EB_NewPri (box,-1);
- EB_AddLastSon (horiz,box);
- EB_AddLastSon (horiz,EB_CreateHorizFill (gadcon,0,0));
- EB_AddLastSon (root,horiz);
- return root;
- }
-
- /**************************************
- PRIVATE: GadgetDown_TwoDim.
- This routine handles the gadget down events passed to the
- TwoDim Control Window.
- **************************************/
- void GadgetDown_TwoDim (UserInputWindowPtr UserWindow, EI_GadgetPtr iaddress) {
- EI_GadgetPtr tgad;
- WORD value;
-
- switch (iaddress->GadgetID) {
- case TWODIM_ID:
- TwoDimX_Value = ((EGB_TwoDimPropGadPtr)iaddress)->HValue;
- TwoDimY_Value = ((EGB_TwoDimPropGadPtr)iaddress)->VValue;
- if (tgad=myFindGadget (UserWindow->GadCon,TWODIM_INTGAD_X_ID)) {
- EB_PutIntData (UserWindow->Window,tgad,TwoDimX_Value);
- }
- if (tgad=myFindGadget (UserWindow->GadCon,TWODIM_INTGAD_Y_ID)) {
- EB_PutIntData (UserWindow->Window,tgad,TwoDimY_Value);
- }
- break;
- case TWODIM_INTGAD_X_ID:
- value=((EI_IntGadPtr)iaddress)->Value;
- // Good Value. Change Two D PropGadget.
- if ((value>=0)&&(value<=100)) {
- TwoDimX_Value=value;
- if (tgad=myFindGadget (UserWindow->GadCon,TWODIM_ID)) {
- EGB_ModifyTwoDPropGadget (UserWindow->Window,tgad,120,20,TwoDimX_Value,
- 120,20,TwoDimY_Value);
- }
- }
- // Bad Value. Change Int Gad back to old value.
- else {
- EB_PutIntData (UserWindow->Window,iaddress,TwoDimX_Value);
- EI_RefreshGadget (UserWindow->Window,iaddress);
- }
- break;
- case TWODIM_INTGAD_Y_ID:
- value=((EI_IntGadPtr)iaddress)->Value;
- if ((value>=0)&&(value<=100)) {
- TwoDimY_Value=value;
- if (tgad=myFindGadget (UserWindow->GadCon,TWODIM_ID)) {
- EGB_ModifyTwoDPropGadget (UserWindow->Window,tgad,120,20,TwoDimX_Value,
- 120,20,TwoDimY_Value);
- }
- }
- // Bad Value. Change Int Gad back to old value.
- else {
- EB_PutIntData (UserWindow->Window,iaddress,TwoDimY_Value);
- EI_RefreshGadget (UserWindow->Window,iaddress);
- }
- break;
- }
- }
-
-
- /**************************************
- PUBLIC: Redraw_TwoDim.
- This routine is called on a EI_iREFRESHWINDOW message.
- If you have nothing to refresh, set the TwoDim_Request.Refresh
- to NULL.
- **************************************/
- void Redraw_TwoDim (UserInputWindowPtr UserWindow) {
- EI_GadgetPtr tgad;
-
- // EB_PutIntData automatically refreshes the gadget if
- // its on screen.
- if (tgad=myFindGadget (UserWindow->GadCon,TWODIM_INTGAD_X_ID)) {
- EB_PutIntData (UserWindow->Window,tgad,TwoDimX_Value);
- }
- if (tgad=myFindGadget (UserWindow->GadCon,TWODIM_INTGAD_Y_ID)) {
- EB_PutIntData (UserWindow->Window,tgad,TwoDimY_Value);
- }
-
- if (tgad=myFindGadget (UserWindow->GadCon,TWODIM_ID)) {
- EGB_ModifyTwoDPropGadget (UserWindow->Window,tgad,120,20,TwoDimX_Value,
- 120,20,TwoDimY_Value);
- }
- }
-